package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dao.SysPlayMapper;
import com.jk.smartelderlycare.dto.SysPlay;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysPlayService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysPlayServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/15 13:11
 */
@Service
public class SysPlayServiceImpl implements SysPlayService {
    @Autowired
    public SysPlayMapper sysPlayMapper;
    /**
     * @description: 后端分页查询
     * @param: [sysPlay, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysPlay>
     * @author hhk
     * @date: 2024/11/15 13:13
     */
    @Override
    public PagedResponse<SysPlay> findSysPlayPaginationList(SysPlay sysPlay, Integer pageNum, Integer pageSize) {
        Page<SysPlay> page = new Page<>(pageNum,pageSize);
        IPage<SysPlay> sysPlayIPage = sysPlayMapper.findSysPlayPaginationList(sysPlay,page);
        return PaginationUtil.getPagedResponse(sysPlayIPage.getRecords(),pageNum,pageSize,sysPlayIPage.getTotal());
    }
    /**
     * @description: 新增
     * @param: [sysPlay]
     * @return: void
     * @author hhk
     * @date: 2024/11/15 13:15
     */
    @Override
    public void addSysPlay(SysPlay sysPlay) {
        sysPlayMapper.insert(sysPlay);
    }
    /**
     * @description: 根据id删除
     * @param: [playId]
     * @return: void
     * @author hhk
     * @date: 2024/11/15 13:16
     */
    @Override
    public void deleteSysPlayById(Long playId) {
        sysPlayMapper.deleteById(playId);
    }
    /**
     * @description: 根据id回显
     * @param: [playId]
     * @return: void
     * @author hhk
     * @date: 2024/11/15 13:16
     */
    @Override
    public SysPlay findSysPlayById(Long playId) {
        return  sysPlayMapper.selectById(playId);
    }
    /**
     * @description: 修改
     * @param: [sysPlay]
     * @return: void
     * @author hhk
     * @date: 2024/11/15 13:16
     */
    @Override
    public void updateSysPlay(SysPlay sysPlay) {
        sysPlayMapper.updateById(sysPlay);
    }
    /**
     * @description: 批量删除
     * @param: [ids]
     * @return: void
     * @author hhk
     * @date: 2024/11/15 13:46
     */
    @Override
    public void deleteSysPlayByIds(List<Long> ids) {
        sysPlayMapper.deleteBatchIds(ids);
    }
}
